﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CommonLib;

namespace sample02
{
    public partial class Form1 : Form
    {
        static int ImageWidth = 800;
        static int ImageHeight = 600;
        private CommonLib.Tracer tracer;
        public Form1()
        {
            InitializeComponent();
            initializeTracer();
        }

        private void initializeTracer()
        {
            CommonLib.Screen screen = new CommonLib.Screen(
                new Vector3c(-4, 3, 0), 
                new Vector3c(4, 3, 0), 
                new Vector3c(-4, -3, 0),
                ImageWidth, ImageHeight, 
                new Vector3c(0, 0, -5));
            CommonLib.Scene scene = new CommonLib.Scene();
            tracer = new CommonLib.Tracer(screen, scene);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            pictureBox1.Image = tracer.Screen.Buffer;
            this.ClientSize = pictureBox1.Size;
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Stopwatch swatch = new System.Diagnostics.Stopwatch();

            swatch.Start();
            tracer.render();
            pictureBox1.Refresh();
            swatch.Stop();

            System.Windows.Forms.MessageBox.Show(swatch.Elapsed.ToString());
        }
    }
}
